<?php defined('RUN_KATANA') or die('Restricted access');
class ProductBrand extends Object
{
	public $Title;
	public $TitleImport;
	public $Country;
	public $Active;
	public $Providers;
	public $ProviderLoaded;
	
	public function ProductBrand() 
	{ 
		self::setDataChanged(false);
		self::setProvidersLoaded(false);
	}
	
	public function __toString()
	{
		$out  = self::getTitle();
		$out .= ' '.self::getCountry();
		return $out;
	}
	
	public function getTitle() { return $this->Title;  }
	public function getTitleImport() { return $this->TitleImport;  }
	public function getCountry() { return $this->Country;  }
	public function getActive() { return intval($this->Active); }
	/* Brands */
	public function getProvider($id=0) 
	{
		if($id > 0)
		{
			//self::loadProviders();
			if(isset($this->Providers[$id]))
			{ return $this->Providers[$id]; }
		}
	}
	public function getProviders() 
	{
		//self::loadProviders();
		return $this->Providers; 
	}
	public function getProvidersLoaded() { return $this->ProvidersLoaded; }
	/* Groups */
	
	public function setTitle($val) { $this->Title=$val;  }
	public function setTitleImport($val) { $this->TitleImport=$val;  }
	public function setCountry($val) { $this->Country=$val;  }
	public function setActive($val) { $this->Active=intval($val); }
	public function setProvidersLoaded($val) { $this->ProvidersLoaded=$val; }
	
	public function update()
	{
		if((self::getId() > 0) && (self::getDataChanged()))
		{
			$sql  = 'UPDATE '.DB_PERFIX.'product_brands SET ';
			$sql .= '`title`="'.self::formatText(self::getTitle()).'", ';
			$sql .= '`title_import`="'.self::formatText(self::getTitleImport()).'", ';
			$sql .= '`country`="'.self::formatText(self::getCountry()).'" ';
			$sql .= ' WHERE id='.self::getId().' LIMIT 1;';
			mysql_query($sql);
		}
	}
}
?>